<template>
	<view :class="[{transparency: !deviceIsOnline()}]">
		<u-radio-group :disabled='!deviceIsOnline()'  v-model="radiovalue1" placement="row" activeColor='#BD9D5F' @change="groupChange">
			<view  v-for="(item, index) in radiolist1">
				<u-radio  :customStyle="{marginBottom: '8px'}" :key="index"
					:label="item.name" :name="item.name" @change="radioChange">
				</u-radio>
				<view style="width: 160rpx;"></view>
			</view>
		</u-radio-group>
	</view>
</template>

<script>
	export default {
		name: "radio-module",
		data() {
			return {
				
				equipmentSatus: {
					offline: 1, //离线,
					online: 2, //在线
					newEquipment: 3 //新设备
				},
				isDisabled: false,
				// 基本案列数据
				radiolist1: [{
						name: '自动',
						disabled: false
					},
					{
						name: '手动',
						disabled: false
					}
				],
				// u-radio-group的v-model绑定的值如果设置为某个radio的name，就会被默认选中
				radiovalue1: '自动',
			};
		},
		
		//组件初始化
		created() {
			let luminance = this.vuex_select_equipment.light;
			this.radiovalue1 = luminance[1] == '1' ? '自动' : '手动' ; 
		},
		
		//方法
		methods: {
			
			//判断设备是否在线
			 deviceIsOnline(){				 
				 if(this.vuex_select_equipment.mac == this.vuex_new_equipment.mac){
					 return this.vuex_new_equipment.status == this.equipmentSatus.online;
				 }else{
					return this.vuex_select_equipment.status == this.equipmentSatus.online;
				 }
			 },
			
			groupChange(n) {
				//打开亮度调节
				let isOpen = n == "手动";
				console.log(isOpen);
				this.$emit('openBrightnessControl',isOpen)
			},
			radioChange(n) {
				//打开亮度调节
				let isOpen = n == "手动";
				console.log(isOpen);
				this.$emit('openBrightnessControl',isOpen)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.transparency{
		opacity: 0.5;
	}
</style>